package com.yuexunit.operationman.nbsy.module.nurse.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


import com.yuexunit.operationman.nbsy.R;
import com.yuexunit.operationman.nbsy.config.AppConfig;
import com.yuexunit.operationman.nbsy.module.nurse.Bean.NurseBean;
import com.yuexunit.operationman.nbsy.module.nurse.ui.Act_Ops_Preview;

import org.kymjs.kjframe.ui.KJFragment;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by chenss on 2017/7/10 0010.
 */

public class Fragment_end_operation extends KJFragment {

    @Bind(R.id.skin_conditions)
    TextView skinConditions;
    @Bind(R.id.frag_end_01)
    TextView fragEnd01;
    @Bind(R.id.frag_end_02)
    TextView fragEnd02;
    @Bind(R.id.frag_end_03)
    TextView fragEnd03;
    @Bind(R.id.AP_Sign)
    TextView APSign;
    @Bind(R.id.operation_name)
    TextView operationName;
    @Bind(R.id.operation_diagnose)
    TextView operationDiagnose;
    private Act_Ops_Preview aty;
    protected View mMainView;

    @Override
    protected View inflaterView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
        aty = (Act_Ops_Preview) getActivity();
        mMainView = inflater.inflate(R.layout.fragment_end_operation, container, false);
        ButterKnife.bind(this, mMainView);
        return mMainView;
    }

    @Override
    protected void initData() {
        for (NurseBean.ObjectEntity.NursingItemListEntity p : AppConfig.NURSEBEAN.getObject().getNursingItemList()) {
            switch (p.getItemCode()) {
                case "AP_ShouShuMingChen":
                    if (p.getItemValue().length() > 0) {
                        operationName.setText(p.getItemValue());
                    }
                    break;
                case "AP_ShuHouZhenDuan":
                    if (p.getItemValue().length() > 0) {
                        operationDiagnose.setText(p.getItemValue());
                    }
                    break;
                case "AP_Skin":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        String[] arrays = getResources().getStringArray(R.array.nursing_end_01);
                        String content = "";
                        if (skin[0].equals("1")) {
                            content += arrays[0];
                        }
                        if (skin[1].equals("1")) {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[1];
                            } else {
                                content += arrays[1];
                            }
                        }
                        skinConditions.setText(content);
                    }
                    if (p.getItemOther().length() > 0) {
                        String[] arrays = getResources().getStringArray(R.array.nursing_end_01);
                        String content = "";
                        if (content.length() > 0) {
                            content += "\n";
                            content += arrays[2] + ":" + p.getItemOther();
                        } else {
                            content += arrays[2] + ":" + p.getItemOther();
                        }
                        skinConditions.setText(content);
                    }
                    break;
                case "AP_YiShiQingKuang":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        String[] arrays = getResources().getStringArray(R.array.nursing_pre_09);
                        if (skin[0].equals("1")) {
                            fragEnd01.setText(arrays[0]);
                        } else if (skin[1].equals("1")) {
                            fragEnd01.setText(arrays[1]);
                        } else if (skin[2].equals("1")) {
                            fragEnd01.setText(arrays[2]);
                        }
                    }
                    break;
                case "AP_ShuHouSongHui":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        String content = "";
                        String[] arrays = getResources().getStringArray(R.array.nursing_end_02);
                        if (skin[0].equals("1")) {
                            content += arrays[0];
                        }
                        if (skin[1].equals("1")) {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[1];
                            } else {
                                content += arrays[1];
                            }
                        }
                        if (skin[2].equals("1")) {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[2];
                            } else {
                                content += arrays[2];
                            }
                        }
                        if (skin[3].equals("1")) {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[3];
                            } else {
                                content += arrays[3];
                            }
                        }

                        fragEnd02.setText(content);
                    }
                    break;
                case "AP_LiShiShiJian":
                    if (p.getItemOther().length() > 0) {
                        fragEnd03.setText(p.getItemOther());
                    }
                    break;
                case "AP_Over_Sign":
                    if (p.getItemName().length() > 0) {
                        APSign.setText(p.getItemName());
                    }
                    break;
            }
        }
    }

}
